/*
 */

package labeledbox;

import java.awt.Graphics;
import java.util.Vector;
import javax.swing.JPanel;

/**
 */
public class CanvasShape extends JPanel {

  Vector<Shape> shapes = new Vector<Shape>();  // a list of the shapes the canvas is supposed to draw.

  // Constructor
  public CanvasShape()  {
    
  }

  // returns a list of the shapes that have been registered with this canvas.
  public Vector<Shape> getShapes() {

    return shapes;
  }

  // Adds a shape to this canvas
  void add(Shape shape) {

    shapes.add(shape);
  }

  // Iterates through the shapes that have been registered with this canvas
  //  and calls each of their draw methods.
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    for (Shape shape : shapes) {
      shape.draw(g);
    }
    
  } //// end paintComponent() /////////
  

} //////////////////// end class CanvasShape /////////////////////////////
